package com.lantosec.hmrp.modules.sysdata.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.lantosec.hmrp.core.mvc.BaseEntity;
import com.lantosec.hmrp.modules.sysdata.vo.SysDataListVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * <p>
 * 系统数据列表定义表 实体类
 * </p>
 *
 * @author AutoCode
 * @since 2020-03-02
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SysDataList extends BaseEntity<SysDataListVO> {

    private static final long serialVersionUID = 1L;
    /**
     * 数据列表ID
     */
    @TableId(value = "data_list_id", type = IdType.ASSIGN_UUID)
    private String dataListId;
    /**
     * 数据列表名称
     */
    private String dataListName;
    /**
     * 对应的数据模型ID
     */
    private String dataModelId;
    /**
     * 数据列表类型(1系统内表2系统外表)
     */
    private Integer dataListType;
    /**
     * 数据列表布局JSON
     */
    private String dataListLayout;
    /**
     * 对应的字段名称
     */
    private String keyField;
    /**
     * 是否允许编辑标志(0否1是)
     */
    private Boolean editFlag;
    /**
     * SQL语句
     */
    private String sqlStr;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 最后修改时间
     */
    private Date editTime;

    public SysDataList(SysDataListVO vo) {
        this.dataListId = vo.getDataListId();
        this.dataListName = vo.getDataListName();
        this.dataModelId = vo.getDataModelId();
        this.dataListType = vo.getDataListType();
        this.dataListLayout = vo.getDataListLayout();
        this.keyField = vo.getKeyField();
        this.editFlag = vo.getEditFlag();
        this.sqlStr = vo.getSqlStr();
        this.createTime = vo.getCreateTime();
        this.editTime = vo.getEditTime();
    }

    @Override
    public SysDataListVO convertToVO() {
        return new SysDataListVO(this);
    }


    public enum ColName {
        data_list_id, data_list_name, data_modle_id, data_list_type, data_list_layout, key_filed, edit_flag, sql_str, create_time, edit_time,
    }
}
